<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-cf">集列表</div>
                </div>
                <div class="widget-body am-fr">
                    <div class="am-scrollable-horizontal am-u-sm-12">
                        <table width="100%" class="am-table am-table-compact am-table-striped
                         tpl-table-black am-text-nowrap">
                            <thead>
                            <tr>
                                <th>视频标题</th>
                                <th>视频集数</th>
                                <th>观看等级</th>
                                <th>视频地址</th>
                                <th>添加时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php if ($list): foreach ($list as $item): ?>
                                <tr>
                                    <td class="am-text-middle">
                                        <p class="item-title"><?= $item['video_name'] ?></p>
                                    </td>
                                    <td class="am-text-middle">第<?= $item['gather_no'] ?>集</td>
                                    <td class="am-text-middle"><?= $item['grade'] ?></td>
                                    <td class="am-text-middle"><?= $item['video_url'] ?></td>
                                    <td class="am-text-middle"><?= date('Y-m-d H:i:s',$item['create_time']) ?></td>
                                    <td class="am-text-middle">
                                        <div class="tpl-table-black-operation">
                                            <?php if (checkPrivilege('movies.video/deleteGather')): ?>
                                                <a href="javascript:;" class="item-delete tpl-table-black-operation-del"
                                                   data-id="<?= $item['gather_id'] ?>">
                                                    <i class="am-icon-trash"></i> 删除
                                                </a>
                                            <?php endif; ?>
                                        </div>
                                    </td>
                                </tr>
                            <?php endforeach; else: ?>
                                <tr>
                                    <td colspan="9" class="am-text-center">暂无记录</td>
                                </tr>
                            <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">
                        <div class="am-fr"></div>
                        <div class="am-fr pagination-total am-margin-right">
                            <div class="am-vertical-align-middle">总记录：<?= count($list) ?></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {

        // 房间状态
        $('.j-state').click(function () {
            // 验证权限
            if (!"<?= checkPrivilege('movies.video/state')?>") {
                return false;
            }
            var data = $(this).data();
            layer.confirm('确定要' + (parseInt(data.state) === 10 ? '下架' : '上架') + '该视频吗？'
                , {title: '友情提示'}
                , function (index) {
                    $.post("<?= url('movies.video/state') ?>"
                        , {
                            video_id: data.id,
                            state: Number(!(parseInt(data.state) === 10))
                        }
                        , function (result) {
                            result.code === 1 ? $.show_success(result.msg, result.url)
                                : $.show_error(result.msg);
                        });
                    layer.close(index);
                });
        });

        // 删除元素
        var url = "<?= url('movies.video/deleteGather') ?>";
        $('.item-delete').delete('gather_id', url);

    });
</script>

